//
//  CZComposeMenuButton.swift
//  weibo
//
//  Created by Apple on 16/3/17.
//  Copyright © 2016年 KY. All rights reserved.
//

import UIKit

class CZComposeMenuButton: UIButton {

    //  重写其高亮属性, 如果不重写set方法，点击动画出现问题
    override var highlighted: Bool {
        get {
            return false
        } set {
            
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        titleLabel?.textAlignment = .Center
        imageView?.contentMode = .Center
        titleLabel?.font = UIFont.systemFontOfSize(14)
        setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        //  设置图片的高度和宽度等于我们button的宽度
        imageView?.width = width
        imageView?.height = width
        //  设置坐标
        imageView?.y = 0
        imageView?.x = 0
        
        //  文本的宽度等于button的宽度，高度等于button的高度减去imageview的高度
        
        titleLabel?.width = width
        titleLabel?.height = height - width
        titleLabel?.y = width
        titleLabel?.x = 0
        
    }

}
